package com.zzw.basic.io;

import java.io.File;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class RandomFileChannelTest {

	public static void main(String[] args) {
		File file = new File("../ReflectDemo/src/main/resources/test.txt");
		try {
			RandomAccessFile raf = new RandomAccessFile(file, "rw");
			FileChannel channel = raf.getChannel();
			ByteBuffer buffer = channel.map(FileChannel.MapMode.READ_WRITE, 0, file.length());
			channel.position(file.length());
			channel.write(buffer);
			buffer.clear();
			System.out.println(buffer.get());
		} catch (Exception e) {
			
		}
	}

}
